import axios from 'axios'


const http = axios.create({
    timeout: 5000
});


//请求拦截
http.interceptors.request.use(
    config => { 
        console.log("request config " + JSON.stringify(config));
        config.headers['token'] =  this.$store.getters.userToken;
    }, 
    error => {
        //处理错误
        return Promise.reject(error)
    }
);

//返回拦截
http.interceptors.response.use(
    (response) => {
        console.log("response: " + JSON.stringify(response));
        return response;
    },
    (error) => {
        return Promise.reject(error);
    }
);

export default http;